package com.kstech.mp3604

import com.blankj.utilcode.util.GsonUtils
import org.junit.Assert.assertEquals
import org.junit.Test


/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
class ExampleUnitTest {
    @Test
    fun addition_isCorrect() {
        assertEquals(4, 2 + 2)
    }

    data class JsonClass(
        val name: String,
        val age: Int,
        val arr: ArrayList<String>,
        val test: String,
        val fe: String
    ) {

    }

    @Test
    fun main() {


//        val result = GsonUtils.toJson(
//            arrayListOf(
//                JsonClass("你好1", 12, arrayListOf("12313", "123", "123")),
//                JsonClass("你好2", 12, arrayListOf("12313", "123", "123")),
//                JsonClass("你好3", 12, arrayListOf("12313", "123", "123"))
//            )
//        )
//        println(result)
        val res1 = "{\"name\":\"你好1\",\"age\":12,\"arr\":[\"12313\",\"123\",\"123\"]}"
        val res =
            "[{\"name\":\"你好1\",\"age\":12,\"arr\":[\"12313\",\"123\",\"123\"]},{\"name\":\"你好2\",\"age\":12,\"arr\":[\"12313\",\"123\",\"123\"]},{\"name\":\"你好3\",\"age\":12,\"arr\":[\"12313\",\"123\",\"123\"]}]"

        val result2 = GsonUtils.fromJson(res, Array<JsonClass>::class.java)
        result2.forEach {
            println(it.toString())
        }

    }
}